//
//  HomeViewController.swift
//  WeiBo
//
//  Created by Wishing.Star on 2017/1/11.
//  Copyright © 2017年 Wishing.Star. All rights reserved.
//

import UIKit

class HomeViewController: BaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func showFriends() {
//        print(#function)
        //实例化需要入栈的子页面
        let vc = DemoViewController()
        //入栈子页面时，隐藏页面下方无关的按钮
        //此方法使用针对所有rootVC的子页面时，都需要调用，容易遗忘，所以使用在NavigationController中重写push方法来实现
//        vc.hidesBottomBarWhenPushed = true
        //导航控制器入栈子页面
        navigationController?.pushViewController(vc, animated: true)
        
    }
    

}

// MARK: - 设置界面
extension HomeViewController {
    //重写父类的方法，设置Push功能，为入栈子子页面做部署
    override func SetupUI() {
        super.SetupUI()
        
        
        //导航栏按钮无法实现按钮
        //设置导航按钮
//        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "好友", style: .plain, target: self, action: #selector(showFriends)) //selector首字母小写
        
        //设置按钮到到导航栏
//        ///引用OC工具方法时，返回instancetype使swift无法推导准确类型，在申明时需要制定类型
//        let navBtn: UIButton = UIButton.cz_textButton("好友", fontSize: 16, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
//        //设置按钮功能
//        navBtn.addTarget(self, action: #selector(showFriends), for: .touchUpInside)
//        //将navBtn转换为UIBarButtonItem，并在leftBarButtonItem替换使用
//        navigationItem.leftBarButtonItem = UIBarButtonItem(customView: navBtn)
        //使用便利构造函数扩展的方法 extensionNavigationButton.swift
//        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "好友", target: self, action: #selector(showFriends))
        //替换默认的navigationItem为自定义navItem
        navItem.leftBarButtonItem = UIBarButtonItem(title: "好友", target: self, action: #selector(showFriends))
        
    }
}
